﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Leadtools;
using Leadtools.Controls;
using Leadtools.Dicom;
using Leadtools.DicomDemos;

namespace DICOMViewer.Utility
{
    class ImageConverter
    {
        void Convert(DicomDataSet ds)
        {
//            DicomElement element;
//            element = ds.FindFirstElement(null, DemoDicomTags.PixelData, true);
//            if (element == null)
//                continue;
//
//            for (int i = 0; i < ds.GetImageCount(element); i++)
//            {
//                RasterImage image;
//                DicomImageInformation info = ds.GetImageInformation(element, i);
//                image = ds.GetImage(element, i, 0, info.IsGray ? RasterByteOrder.Gray : RasterByteOrder.Rgb,
//                    DicomGetImageFlags.AutoApplyModalityLut |
//                    DicomGetImageFlags.AutoApplyVoiLut |
//                    DicomGetImageFlags.AllowRangeExpansion);
//                //ds.
//                    
//            }

        }

        public static void ConvertJpeg2000(DicomDataSet ds)
        {
            DicomJpeg2000Options options = ds.DefaultJpeg2000Options;
            options.CompressionControl = DicomJpeg2000CompressionControl.Lossless;
            Console.WriteLine("Changed CompressionControl to DicomJpeg2000CompressionControl.Ratio and DicomJpeg2000CompressionControl.CompressionRatio to 50");
            //https://www.leadtools.com/help/leadtools/v19/dh/di/dicomdataset-setimage.html
            ds.Jpeg2000Options = options;
            ds.ChangeTransferSyntax(DicomUidType.JPEG2000, 2, ChangeTransferSyntaxFlags.None);
        }
    }
}
